﻿#define _crt_secure_no_warnings

#include <stdio.h>
#ifdef __cplusplus
#define null 0
#else
#define null ((void *)0)
#endif

int main()
{
	
	int num = 10;
	int* p1 = &num;
	int* p2 = null;

	return 0;

}
int main()
{
	int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
	int* p = &arr[0];
    for (int i = 0; i < 10; i++) 
	{
		*(p++) = i;
		printf("%d\n", *p);
	}
	//此时p已经越界了，可以把p置为null
	p = null;
	//下次使⽤的时候，判断p不为null的时候再使⽤
	//...
	p = &arr[0];//重新让p获得地址
	if (p != null) //判断
	{
		//...
	}
	return 0;
}







#define ndebug//不在使用assert
#include <assert.h>

int main()
{
	int a = 10;
	int* p = &a;
	assert(p != null);
	*p = 20;
	printf("%d\n", a);

	return 0;
}

int main()
{
	int a = 0;
	scanf("%d", &a);
	assert(a != 0);
	printf("%d\n", a);

	return 0;
}


int my_strlen(const char* str)
{
	int count = 0;
	assert(str);
	while (*str)
	{
		count++;
		str++;
	}
	return count;
}
int main()
{
	int len = my_strlen("abcdef");
	printf("%d\n", len);
	return 0;
}


int main()
{
    int j = 0;
    int i = 0;
    char a = 0;
    scanf("%c", &a);
    for (i = 0; i < 5; i++)
    {
        for (j = 0; j < 5; j++)
        {
            if ((i == 0) && (j == 2))
            {
                printf("%c", a);
            }
            else if ((i == 1) && ((j == 2) || (j == 3) || (j == 4)))
            {
                printf("%c", a);
            }
            else if (i == 2)
            {
                printf("%c", a);

            }
            else if ((i == 3) && ((j == 2) || (j == 3) || (j == 4))) {
                printf("%c", a);
            }
            else if ((i == 4) && (j == 2)) {
                printf("%c", a);
            }
            else
            {
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;

}



size_t my_strlen(const char* s)
{
	int count = 0;
	while (*s != '\0')
	{
		count++;
			s++;
	}
	return count;
}
int main()
{
	char arr[] = "abcdef";
	int len = my_strlen(arr);
	printf("%d\n", len);
	return 0;
}

int main()
{
	int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
	printf("&arr[0] = %p\n", &arr[0]);
	printf("arr = %p\n", arr);
	return 0;
}



int main()
{
	int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
	printf("&arr[0] = %p\n", &arr[0]);
	printf("arr = %p\n", arr);
	printf("&arr = %p\n", &arr);
	return 0;
} 
int main()
{
	int arr[10] = { 0 };
	//输⼊
	int i = 0;
	int sz = sizeof(arr) / sizeof(arr[0]);
	//输⼊
	int* p = arr;
	for (i = 0; i < sz; i++)
	{
		scanf("%d", p + i);
		scanf("%d", arr+i);//也可以这样写
	}
	//输出
	for (i = 0; i < sz; i++)
	{
		printf("%d ", *(p + i));
	}
	return 0;
}

int main()
{
	int arr[10] = { 0 };
	//输⼊
	int i = 0;
	int sz = sizeof(arr) / sizeof(arr[0]);
	//输⼊
	int* p = arr;
	for (i = 0; i < sz; i++)
	{
		scanf("%d", p + i);
		//scanf("%d", arr+i);//也可以这样写
	}
	//输出
	for (i = 0; i < sz; i++)
	{
		printf("%d ", p[i]);
	}
	return 0;
}

// arr[1]=*(arr+i)=*(p+i)=p[i]=i[arr]=*(i+arr]




size_t my_strlen(const char* s)
{
	int count = 0;
	while (*s != '\0')
	{
		count++;
		s++;
	}
	return count;
}
int main()
{
	char arr[] = "abcdef";
	printf("%c\n", arr[0]);
	int len = my_strlen(arr);
	printf("%d\n", len);
	return 0;
}

void test(int arr[])//参数写成数组形式，本质上还是指针
{
	printf("%d\n", sizeof(arr));
}
void test(int* arr)//参数写成指针形式
{
	printf("%d\n", sizeof(arr));//计算⼀个指针变量的⼤⼩
}
int main()
{
	int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
	test(arr);
	return 0;
}
 总结：⼀维数组传参，形参的部分可以写成数组的形式，也可以写成指针的形式。

int main()
{
	int a = 10;
	int* p = &a;
	int** pp = &p; 
	**pp = 20;
	printf("%d\n", a);
	return 0;
}
  





